<template>
	<div>
		<el-form style="margin-top: 50px;" label-width="80px">
			<el-form-item label="标题:">
				<el-input v-model="login.title"></el-input>
			</el-form-item>
			<br />
			<el-form-item label="类别:">
				<el-input v-model="login.category"></el-input>
			</el-form-item>
			<label>请上传视频：</label>
			<input @change="getvideo" type="file" />
		</el-form>
		<el-button style="margin-top: 20px;" type="primary" @click="addvideo()">上 传</el-button>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				video: "",
				login: {
					"title":"",
					"category":""
				}
			}
		},
		methods: {
			addvideo() {
				let url = "addvideo/"+window.sessionStorage.getItem("token");
				// console.log(url);
				let data = new FormData();
				data.append('video', this.video);
				data.append('title', this.login.title);
				data.append('category', this.login.category);
				this.$http.post(url, data).then(res => {
					// console.log(res.data);
					if (res.data.status == 2000) {
						this.$message.success("添加成功");
					} else {
						this.$message.error("添加失败");
					}
			
				})
			},
			getvideo(e){
				let file = e.target.files[0];
				this.video = file;
			},
		}
	}
</script>

<style>
</style>
